<?php
/**
* @file php_adm.php
* Admin Systemblock php
*
* @author PortaMx - Portal Management Extension
* @author Copyright 2008-2011 by PortaMx - http://portamx.com
* @Version: 1.0 RC4
* @Date: 23.02.2011
*/

if(!defined('PortaMx'))
	die('This file can\'t be run without PortaMx');

/**
* @class pmxc_php_adm
* Admin Systemblock php_adm
* @see php_adm.php
* @author Copyright by PortaMx - http://portamx.com
*/
class pmxc_php_adm extends PortaMxC_SystemAdminBlock
{
	/**
	* AdmBlock_init().
	* Setup caching.
	*/
	function pmxc_AdmBlock_init()
	{
		$this->can_cached = 0;			// disable caching
	}

	/**
	* AdmBlock_settings().
	* Setup the config vars and output the block settings.
	* Returns the css classes they are used.
	*/
	function pmxc_AdmBlock_settings()
	{
		global $context, $txt;

		// define the settings options
		echo '
					<td valign="top" style="padding:4px;">
						<input type="hidden" name="config[settings]" value="" />
						<div style="height:169px;">
							<div class="cat_bar catbg_grid grid_padd">
								<h4 class="catbg catbg_grid"><span class="cat_left_title">'. sprintf($txt['pmx_blocks_settings_title'], $this->register_blocks[$this->cfg['blocktype']]['description']) .'</span></h4>
							</div>'.
							$txt['pmx_defaultsettings'] .'
						</div>';

		// return the used classnames
		return $this->block_classdef;
	}

	/**
	* AdmBlock_content().
	* Open a textarea, to create or edit the content.
	* Returns the AdmBlock_settings
	*/
	function pmxc_AdmBlock_content()
	{
		global $context, $options, $txt;

		// show the content area
		$options['collapse_phpinit'] = empty($context['pmx']['editorID_init']['havecont']);

		echo '
					<td valign="top" colspan="2" style="padding:4px;">
						<div class="cat_bar catbg_grid">
							<h4 class="catbg catbg_grid"><span class="cat_left_title">'. $txt['pmx_edit_content'] .'
								<span id="upshrinkPHPinitCont"'. (empty($options['collapse_phpinit']) ? '' : ' style="display:none;"') .'>'. $txt['pmx_edit_content_show'] .'</span></span>
							</h4>
						</div>
						<div>', template_control_richedit($context['pmx']['editorID']) ,'</div>

						<div class="plainbox" style="margin: 5px 0; padding: 7px 0 5px 0;">
							<div class="normaltext" style="margin:0 10px;">
							'.(empty($context['pmx']['editorID_init']['havecont']) ?
								'<img id="upshrinkPHPshowImg" src="'. (empty($options['collapse_phpinit']) ? $context['pmx_img_expand'] : $context['pmx_img_colapse']) .'" alt="*" title="'. (empty($options['collapse_phpinit']) ? $txt['pmx_collapse'] . $txt['pmx_php_partblock'] : $txt['pmx_expand'] . $txt['pmx_php_partblock']) .'" />&nbsp;' : '') .'
								<span>'. $txt['pmx_php_partblock_note'] .'
									<img class="info_toggle" onclick=\'Toggle_help("pmxPHPH01")\' src="'. $context['pmx_imageurl'] .'information.gif" alt="*" title="'. $txt['pmx_information_icon'] .'" />
								</span>
							</div>
							<div id="pmxPHPH01" style="display:none; margin:4px 10px 0;">'. $txt['pmx_php_partblock_help'] .'</div>
						</div>

						<div id="upshrinkPHPshowCont"' .(empty($options['collapse_phpinit']) ? '' : ' style="display:none;"') .'>

							<div class="cat_bar catbg_grid">
								<h4 class="catbg catbg_grid"><span class="cat_left_title">'. $txt['pmx_edit_content'] . $txt['pmx_edit_content_init'] .'</span></h4>
							</div>
							<div>', template_control_richedit($context['pmx']['editorID_init']['id']) ,'</div>
						</div>';

		if(empty($context['pmx']['editorID_show']['havecont']))
			echo '
						<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
						var upshrinkPHPshow = new smc_Toggle({
							bToggleEnabled: true,
							bCurrentlyCollapsed: '. (empty($options['collapse_phpinit']) ? 'false' : 'true') .',
							aSwappableContainers: [
								\'upshrinkPHPshowCont\',
								\'upshrinkPHPinitCont\'
							],
							aSwapImages: [
								{
									sId: \'upshrinkPHPshowImg\',
									srcCollapsed: \''. $context['pmx_img_colapse'] .'\',
									altCollapsed: '. JavaScriptEscape($txt['pmx_expand'] . $txt['pmx_php_partblock']) .',
									srcExpanded: \''. $context['pmx_img_expand'] .'\',
									altExpanded: '. JavaScriptEscape($txt['pmx_collapse'] . $txt['pmx_php_partblock']) .'
								}
							]
						});
						// ]]></script>';

		echo '
					</td>
				</tr>
				<tr>';

		// return the default settings
		return $this->pmxc_AdmBlock_settings();
	}
}
?>